/* Copyright [2023] <gyl> */
#pragma once

#include <string>
#include <vector>

#include "common/rc.h"
#include "sql/parser/parse_defs.h"
#include "sql/stmt/stmt.h"

class GrantStmt : public Stmt {
 public:
  GrantStmt(const std::vector<std::string> &table_names,
            const std::vector<std::string> &users, const int priv)
      : table_names_(table_names), users_(users), priv_(priv) {}
  virtual ~GrantStmt() = default;
  StmtType type() const override { return StmtType::GRANT; }

 public:
  static RC create(Db *db, const GrantSqlNode &grant_sql, Stmt *&stmt);
  const std::vector<std::string> &table_names() const { return table_names_; }
  const std::vector<std::string> &users() const { return users_; }
  const int priv() const { return priv_; }
  int **operation() const { return operation_; }
  void set_operation(int **operation) { operation_ = operation; }

 private:
  std::vector<std::string> table_names_;
  std::vector<std::string> users_;
  const int priv_;
  int **operation_;  // 这是个二维数组，0代表INSERT，1代表UPDATE
};
